Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

orderedmap

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orderedmap

Persistent ordered mapping from strings

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
decreased by-4.47%
Maintainers
1
Weekly downloads
 
Created

What is orderedmap?

The orderedmap npm package provides a data structure that maintains the order of keys as they are added. This is useful for scenarios where the order of elements is important, such as in configuration files, ordered collections, or when you need predictable iteration order.

What are orderedmap's main functionalities?

Creating an OrderedMap

This feature allows you to create a new instance of an OrderedMap. The OrderedMap will maintain the order of keys as they are added.

const OrderedMap = require('orderedmap');
const map = new OrderedMap();

Adding and Retrieving Elements

You can add elements to the OrderedMap using the set method and retrieve them using the get method. The order of keys is preserved.

map.set('key1', 'value1');
map.set('key2', 'value2');
console.log(map.get('key1')); // Outputs: 'value1'

Iterating Over Elements

This feature allows you to iterate over the elements in the OrderedMap in the order they were added. This is useful for scenarios where the order of elements is important.

map.set('key1', 'value1');
map.set('key2', 'value2');
for (let [key, value] of map) {
  console.log(key, value);
}

Deleting Elements

You can delete elements from the OrderedMap using the delete method. This will remove the element and maintain the order of the remaining elements.

map.set('key1', 'value1');
map.delete('key1');
console.log(map.has('key1')); // Outputs: false

Other packages similar to orderedmap

Keywords

FAQs

Package last updated on 17 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc